package com.bookshop.service.impl;

import com.bookshop.dao.BookDao;
import com.bookshop.dao.impl.BookDaoImpl;
import com.bookshop.entity.Book;
import com.bookshop.service.BookService;

import java.sql.SQLException;
import java.util.List;

/**
 * 图书业务实现类
 */
public class BookServiceImpl implements BookService {

    //访问dao实现的方法

    @Override
    public List<Book> findBooksByCount(int limit) {
        BookDao bookDao=new BookDaoImpl();
        List<Book> books = null;
        try {
            books = bookDao.findBooksByCount(limit);
        } catch (SQLException throwables) {
            //日志记录
            throwables.printStackTrace();

        }
        return books;
    }

    @Override
    public Book findById(int id) {
        BookDao bookDao=new BookDaoImpl();
        Book book = null;
        try {
            book = bookDao.findById(id);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return book;
    }
}
